const path = require("path");
const webpack = require("webpack");

module.exports = {
  mode: "development",
  entry: "/src/ts/index.ts",
  devtool: "eval-source-map",
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: "ts-loader",
        exclude: /node_modules/,
      },
      {
        test: /\.scss$/,
        use: ["style-loader", "css-loader", "sass-loader"],
      },
      {
        test: /\.art$/,
        loader: "art-template-loader",
      },
    ],
  },
  devServer: {
    static: {
      directory: path.join(__dirname, "..", "demo"),
    },
    hot: true,
    open: true,
    port: 8000,
    compress: true,
  },
  resolve: {
    preferRelative: true,
    extensions: [".tsx", ".ts", ".js"],
  },
  output: {
    filename: "Functool.min.js",
    path: path.resolve(__dirname, "..", "dist"),
    library: {
      name: "tool",
      type: "umd",
      export: "default",
    },
    publicPath: '/dist/'
  },
  plugins: [
    new webpack.DefinePlugin({
      FUNCTOOL_VERSION: `"${require('../package.json').version}"`,
      "process.env": {
        NODE_ENV: JSON.stringify(process.env.NODE_ENV),
      },
    }),
  ],
};
